package com.zhw.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//@Aspect
@Slf4j
@Component
public class myAspect {

    @Pointcut("execution(* com.zhw.service.*.*(..))")
    public void pc(){}

    @After("pc()")
    public void after(){
        log.info("After方法执行了");
    }

    @Before("pc()")
    public void before(){
        log.info("before方法执行了");
    }



    @Around("pc()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        log.info("方法执行前执行的around");

        Object result = pjp.proceed();


        log.info("方法执行后执行的around");
        return result;
    }


    @AfterReturning("pc()")
    public void afterReturning(){
        log.info("原始方法执行完毕");
    }

    @AfterThrowing("pc()")
    public void afterThrowing(){
        log.info("方法有异常信息");
    }
}
